#ifndef __WINDOWS_REGISTRY_H
#define __WINDOWS_REGISTRY_H

#include "TString.h"
#include "string"

class CKey
{
	HKEY _object;
public:
	CKey(): _object(NULL) {}
	~CKey() { Close(); }
	operator HKEY() const { return _object; }
	void Attach(HKEY key) { _object = key; }////
	HKEY Detach()
	{
		HKEY key = _object;
		_object = NULL;
		return key;
	}
	LONG Create(HKEY parentKey, LPCTSTR keyName,
		LPTSTR keyClass = REG_NONE, DWORD options = REG_OPTION_NON_VOLATILE,
		REGSAM accessMask = KEY_ALL_ACCESS,
		LPSECURITY_ATTRIBUTES securityAttributes = NULL,
		LPDWORD disposition = NULL);
	LONG Open(HKEY parentKey, LPCTSTR keyName, REGSAM accessMask = KEY_ALL_ACCESS);
	LONG Close();
	LONG DeleteSubKey(LPCTSTR subKeyName);
	LONG RecurseDeleteKey(LPCTSTR subKeyName);
	LONG SetValue(LPCTSTR valueName, LPCTSTR value);
	LONG SetValue(LPCTSTR valueName, DWORD &value);
	LONG QueryValue(LPCTSTR name, LPTSTR value, unsigned int &dataSize);
	LONG QueryValue(LPCTSTR name, TString &value);
	BOOL GetUnInstallName( std::wstring &vecInstallName );
};

#endif
